package com.gcsoftware.web.mapper.providers;

import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.jdbc.SQL;

import java.text.MessageFormat;
import java.util.List;
import java.util.Set;

/**
 * Created by qs on 2018/4/3.
 */
public class RoleDsiInterfsProvider {
    public String batchInsertInterfs (@Param(value = "c_ROLE_ID") String c_ROLE_ID, @Param(value = "interfList") List<String> interfList) {
        StringBuilder builder = new StringBuilder();
        builder.append("INSERT INTO T_CON_ROLE_INTERFS ");
        builder.append("(C_ROLE_ID,C_INTERF_ID) ").append("VALUES ");
        MessageFormat fmt = new MessageFormat("(#'{'c_ROLE_ID},#'{'interfList[{0}]})");
        for (int i =0; i<interfList.size(); i++) {
            builder.append(fmt.format(new Object[]{i}));
            if (i < interfList.size() - 1) {
                builder.append(",");
            }
        }
        return builder.toString();
    }

    public String batchInsertDsis (@Param(value = "c_ROLE_ID") String c_ROLE_ID, @Param(value = "dsiList") List<String> dsiList) {
        StringBuilder builder = new StringBuilder();
        builder.append("INSERT INTO T_CON_ROLE_DSITEM ");
        builder.append("(C_ROLE_ID,C_DS_ITEM_ID) ").append("VALUES ");
        MessageFormat fmt = new MessageFormat("(#'{'c_ROLE_ID},#'{'dsiList[{0}]})");
        for (int i =0; i<dsiList.size(); i++) {
            builder.append(fmt.format(new Object[]{i}));
            if (i < dsiList.size() - 1) {
                builder.append(",");
            }
        }
        return builder.toString();
    }

}
